package router

import (
	"iris-wms/apps/admin/bootstrap"
	"iris-wms/apps/admin/middleware"
	"iris-wms/apps/admin/web/service"

	"github.com/kataras/iris/v12"
)

// router hub
func Hub(app *bootstrap.Bootstrapper) {
	api := app.Party("/api/admin")
	api.Use(middleware.ServeHTTP)
	// -------------------------------------------------- admin start
	{
		api.Party("/user").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminlUserService())
			route := NewAdminUserRoute()
			r.Post("/login", route.Login).Describe("").Title = "用户~登陆~"
			r.Get("/getUserInfo", route.GetUserInfo).Describe("").Title = "用户~获取用户信息~"
			r.Get("/logout", route.Logout).Describe("").Title = "用户~登出~"
			r.Post("/resetPassword", route.ResetPassword).Describe("").Title = "用户~重置密码~"
			//
			r.Post("/", route.Create).Describe("").Title = "用户~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "用户~删除~"
			r.Put("/", route.Edit).Describe("").Title = "用户~修改~"
			r.Get("/table", route.Table).Describe("").Title = "用户~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "用户~列表~"
			//
			// adminUser.Put("/own/reset_info", hero.Handler(aus.ResetOwnInfo)).Describe("用户管理接口~自己修改自己信息~")
			// adminUser.Put("/own/reset_password", hero.Handler(aus.ResetOwnPassword)).Describe("用户管理接口~自己重置密码~")
		})
		api.Party("/menu").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminMenuService())
			route := NewAdminMenuRoute()
			r.Post("/", route.Create).Describe("").Title = "菜单~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "菜单~删除~"
			r.Put("/", route.Edit).Describe("").Title = "菜单~修改~"
			r.Get("/list", route.List).Describe("").Title = "菜单~列表~"
			r.Get("/ownList", route.OwnList).Describe("").Title = "菜单~拥有的列表~"
		})
		api.Party("/button").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminButtonService())
			route := NewAdminButtonRoute()
			r.Post("/", route.Create).Describe("").Title = "按钮~创建~"
			r.Post("/generate", route.Generate).Describe("").Title = "按钮~生成按钮~"
			r.Put("/", route.Edit).Describe("").Title = "按钮~修改~"
			r.Delete("/", route.Delete).Describe("").Title = "按钮~删除~"
			r.Delete("/generate", route.Generate).Describe("").Title = "按钮~生成系统内置按钮~"
			r.Get("/table", route.Table).Describe("").Title = "按钮~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "按钮~列表~"
		})
		api.Party("/role").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminRoleService())
			route := NewAdminRoleRoute()
			r.Post("/", route.Create).Describe("").Title = "角色~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "角色~删除~"
			r.Put("/", route.Edit).Describe("").Title = "角色~修改~"
			r.Get("/table", route.Table).Describe("").Title = "角色~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "角色~列表~"
			r.Post("/grant", route.Grant).Describe("").Title = "角色~授权~"
			r.Get("/grant/owned", route.Owned).Describe("").Title = "角色~已有的权限~"
		})
		api.Party("/policy").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminPolicyService())
			route := NewAdminPolicyRoute()
			r.Delete("/", route.Delete).Describe("").Title = "接口~删除~"
			r.Get("/table", route.Table).Describe("").Title = "接口~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "接口~列表~"
			r.Put("/log", route.Log).Describe("").Title = "接口~日志埋点~"
		})
		api.Party("/log").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminLogService())
			route := NewAdminLogRoute()
			r.Delete("/", route.Delete).Describe("").Title = "操作日志~删除~"
			r.Get("/table", route.Table).Describe("").Title = "操作日志~管理报表~"
		})
		api.Party("/dict").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewAdminDictService())
			route := NewAdminDictRoute()
			r.Post("/", route.Create).Describe("").Title = "字典~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "字典~删除~"
			r.Put("/", route.Edit).Describe("").Title = "字典~修改~"
			r.Get("/table", route.Table).Describe("").Title = "字典~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "字典~列表~"
			r.Get("/getListByMark", route.GetListByMark).Describe("").Title = "字典~查询mark列表~"
		})
	}

	// -------------------------------------------------- wms start
	{
		wms := api.Party("/wms")
		wms.Party("/warehouse").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsWarehouseService())
			route := NewWmsWarehouseRoute()
			r.Post("/", route.Create).Describe("").Title = "仓库~创建~"
			r.Put("/", route.Edit).Describe("").Title = "仓库~修改~"
			r.Delete("/", route.Delete).Describe("").Title = "仓库~删除~"
			r.Get("/list", route.List).Describe("").Title = "仓库~列表~"
		})
		wms.Party("/warehouse/area").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsWarehouseService())
			route := NewWmsWarehouseAreaRoute()
			r.Post("/", route.Create).Describe("").Title = "库区~创建~"
			r.Put("/", route.Edit).Describe("").Title = "库区~修改~"
			r.Delete("/", route.Delete).Describe("").Title = "库区~删除~"
			r.Get("/list/{wid:uint}", route.List).Describe("").Title = "库区~列表~"
		})
		wms.Party("/goods").ConfigureContainer(func(r *iris.APIContainer) {
			p1 := r.Party("/cate")
			p1.RegisterDependency(service.NewWmsGoodsCateService())
			r1 := NewWmsGoodsCateRoute()
			p1.Post("/", r1.Create).Describe("").Title = "商品分类~创建~"
			p1.Delete("/", r1.Delete).Describe("").Title = "商品分类~删除~"
			p1.Put("/", r1.Edit).Describe("").Title = "商品分类~修改~"
			p1.Get("/list", r1.List).Describe("").Title = "商品分类~列表~"

			p2 := r.Party("/")
			p2.RegisterDependency(service.NewWmsGoodsService())
			r2 := NewWmsGoodsRoute()
			p2.Post("/", r2.Create).Describe("").Title = "商品~创建~"
			p2.Delete("/", r2.Delete).Describe("").Title = "商品~删除~"
			p2.Put("/", r2.Edit).Describe("").Title = "商品~修改~"
			p2.Post("/upImage", r2.UpImage).Describe("").Title = "商品~上传图片~"
			p2.Get("/table", r2.Table).Describe("").Title = "商品~管理报表~"
			p2.Get("/list", r2.List).Describe("").Title = "商品~列表~"
			p2.Get("/getGoodsByCode", r2.GetGoodsByCode).Describe("").Title = "商品~按关键字查询~"
		})
		wms.Party("/customer").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsCustomerService())
			route := NewWmsCustomerRoute()
			r.Post("/", route.Create).Describe("").Title = "客户~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "客户~删除~"
			r.Put("/", route.Edit).Describe("").Title = "客户~修改~"
			r.Get("/table", route.Table).Describe("").Title = "客户~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "客户~列表~"
		})
		wms.Party("/supplier").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsSupplierService())
			route := NewWmsSupplierRoute()
			r.Post("/", route.Create).Describe("").Title = "供应商~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "供应商~删除~"
			r.Put("/", route.Edit).Describe("").Title = "供应商~修改~"
			r.Get("/table", route.Table).Describe("").Title = "供应商~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "供应商~列表~"
		})
		wms.Party("/carrier").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsCarrierService())
			route := NewWmsCarrierRoute()
			r.Post("/", route.Create).Describe("").Title = "供应商~创建~"
			r.Delete("/", route.Delete).Describe("").Title = "供应商~删除~"
			r.Put("/", route.Edit).Describe("").Title = "供应商~修改~"
			r.Get("/table", route.Table).Describe("").Title = "供应商~管理报表~"
			r.Get("/list", route.List).Describe("").Title = "供应商~列表~"
		})
		wms.Party("/bill").ConfigureContainer(func(r *iris.APIContainer) {
			service_ := service.NewWmsBillService()
			//
			p1 := r.Party("/inbound")
			r1 := NewWmsBillInboundRoute()
			p1.RegisterDependency(service_)
			p1.Post("/", r1.Create).Describe("").Title = "入库单~创建~"
			p1.Delete("/", r1.Delete).Describe("").Title = "入库单~删除~"
			p1.Put("/", r1.Edit).Describe("").Title = "入库单~修改~"
			p1.Get("/table", r1.Table).Describe("").Title = "入库单~管理报表~"
			p1.Get("/code", r1.GetByCode).Describe("").Title = "入库单~根据code查询~"
			//
			p2 := r.Party("/outbound")
			r2 := NewWmsBillOutboundRoute()
			p2.RegisterDependency(service_)
			p2.Post("/", r2.Create).Describe("").Title = "出库单~创建~"
			p2.Delete("/", r2.Delete).Describe("").Title = "出库单~删除~"
			p2.Put("/", r2.Edit).Describe("").Title = "出库单~修改~"
			p2.Get("/table", r2.Table).Describe("").Title = "出库单~管理报表~"
			p2.Get("/code", r2.GetByCode).Describe("").Title = "出库单~根据code查询~"
			//
			p3 := r.Party("/move")
			r3 := NewWmsBillMoveRoute()
			p3.RegisterDependency(service.NewWmsBillMoveService())
			p3.Post("/", r3.Create).Describe("").Title = "移库单~创建~"
			p3.Delete("/", r3.Delete).Describe("").Title = "移库单~删除~"
			p3.Put("/", r3.Edit).Describe("").Title = "移库单~修改~"
			p3.Get("/table", r3.Table).Describe("").Title = "移库单~管理报表~"
			p3.Get("/code", r3.GetByCode).Describe("").Title = "移库单~根据code查询~"
			//
			p4 := r.Party("/pandian")
			r4 := NewWmsBillPandianRoute()
			p4.RegisterDependency(service.NewWmsBillPandianService())
			p4.Post("/", r4.Create).Describe("").Title = "盘点单~创建~"
			p4.Delete("/", r4.Delete).Describe("").Title = "盘点单~删除~"
			p4.Put("/", r4.Edit).Describe("").Title = "盘点单~修改~"
			p4.Get("/table", r4.Table).Describe("").Title = "盘点单~管理报表~"
			p4.Get("/code", r4.GetByCode).Describe("").Title = "盘点单~根据code查询~"
			p4.Post("/over", r4.Over).Describe("").Title = "盘点单~盘存结束~"
			p4.Post("/getByGoodsIdListAndWid", r4.GetByGoodsIdListAndWid).Describe("").Title = "盘点单~盘存商品库存查询~"
		})
		wms.Party("/history").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsHistoryService())
			route := NewWmsHistoryRoute()
			r.Get("/history", route.GetInAndOutHistory).Describe("").Title = "库存记录~管理报表~"
		})
		wms.Party("/report").ConfigureContainer(func(r *iris.APIContainer) {
			r.RegisterDependency(service.NewWmsReportService())
			route := NewWmsReportRoute()
			r.Get("/warehouse", route.GetByWarehouse).Describe("").Title = "库存报表~按仓库/库区维度统计~"
			r.Get("/goods", route.GetByGoods).Describe("").Title = "库存报表~按货物维度统计~"
		})
	}
}
